package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {

    /**
     * 查询全部  16:10
     *
     * @return
     */
    @Select("select * from  tb_brand")
 /*   @Results({
            @Result(column ="id" ,property = "id"),
            @Result(column ="brand_name" ,property = "brandName"),
            @Result(column ="company_name" ,property = "companyName"),
            @Result(column ="ordered" ,property = "ordered"),
            @Result(column ="description" ,property = "description"),
            @Result(column ="status" ,property = "status")
    })*/
    public List<Brand> selectAll();

    /**
     * 添加数据
     *
     * @param brand
     */
    @Insert("insert into tb_brand values(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    public void add(Brand brand);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from tb_brand where id = #{id}")
    Brand selectById(String id);

    /**
     * 修改
     * @param brand
     */
    @Update("update tb_brand set brand_name = #{brandName},company_name = #{companyName},ordered = #{ordered},description = #{description},status = #{status} where id = #{id}")
    void update(Brand brand);

    /**
     * 删除数据
     * @param id
     */
    @Delete("delete  from tb_brand where id = #{id}")
    void deleteById(String id);
}
